package com.shop.cart.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

/**
 * @author ghy
 * @version 1.0
 * @date 2020-11-05
 */
@Configuration
public class RabbitMQConfig {

    @Bean
    public Queue cartQueue(){
        return QueueBuilder.durable("cartQueue").build();
    }
    @Bean
    public Exchange cookieExchange(){
        return ExchangeBuilder.topicExchange("cookieExchange").build();
    }

    @Bean
    public Binding binding(@Qualifier("cartQueue") Queue bootConfirmQueue,
                           @Qualifier("cookieExchange") Exchange bootConfirmExchange){
        return BindingBuilder.bind(bootConfirmQueue).to(bootConfirmExchange).with("cart_token.*").noargs();
    }


}
